Component({
  properties: {},

  data: {
    chatBtnBtm: 50,
    chatBtnRgt: 34,
    screenHeight: null,
    screenWidth: null
  },

  attached: function () {
    var that = this

    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          screenHeight: res.windowHeight,
          screenWidth: res.windowWidth
        })
      }
    })
  },

  methods: {

    bindTouchMoveChat: function (e) {
      let touchs = e.touches[0]
      let pageX = touchs.pageX
      let pageY = touchs.pageY
      let halfBtnWidth = 54 / 2 // px (width === height)

      if (
        this.data.screenWidth - pageX < halfBtnWidth || pageX < halfBtnWidth ||
        this.data.screenHeight - pageY < halfBtnWidth || pageY < halfBtnWidth
      ) { return }

      let chatBtnRgt = this.data.screenWidth - pageX - halfBtnWidth
      let chatBtnBtm = this.data.screenHeight - pageY - halfBtnWidth

      this.setData({ chatBtnBtm, chatBtnRgt })
    }
  }
})
